//
//  MaterialSelectViewController.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/18.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "MaterialSelectViewController.h"

#import "MoreMaterialSelectViewController.h"

@interface MaterialSelectViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) BaseTableView *tableView;

@end

@implementation MaterialSelectViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"推荐材质";
    
    self.tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - ScreenX375(49)) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = 0.01;
    self.tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    
    UIButton *connectBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - ScreenX375(49), ScreenX375(258), ScreenX375(49))];
    connectBtn.backgroundColor = REXADECIMALCOLOR(@"#ff9500");
    [connectBtn setTitle:@"有困难请联系我" forState:UIControlStateNormal];
    [connectBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    connectBtn.titleLabel.font = Kfont(14);
    [self.view addSubview:connectBtn];
    
    UIButton *nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(258), SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - ScreenX375(49), SCREEN_WIDTH - ScreenX375(258), ScreenX375(49))];
    nextBtn.backgroundColor = REXADECIMALCOLOR(@"#ed223b");
    [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    nextBtn.titleLabel.font = Kfont(14);
    [nextBtn addTarget:self action:@selector(nextStep) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:nextBtn];
}

- (void)nextStep {
    MoreMaterialSelectViewController *vc = [[MoreMaterialSelectViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc] init];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return ScreenX375(53);
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(53))];
    view.backgroundColor = [UIColor whiteColor];
    
    UIView *rline = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenX375(15), ScreenX375(3), ScreenX375(23))];
    rline.backgroundColor = ThemeColor;
    [view addSubview:rline];
    
    NSArray *noteArr = @[@"类型",@"重量",@"堆码层数",@"内销外销"];
    UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(300), ScreenX375(24))];
    noteLabel.text = noteArr[section];
    noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
    noteLabel.font = Kfont(18);
    [view addSubview:noteLabel];
    
    if (section != 1) {
        UIButton *selectBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(39), 0, ScreenX375(39), ScreenX375(53))];
        [selectBtn setImage:[UIImage imageNamed:@"矢量智能对象拷贝2副本2"] forState:UIControlStateNormal];
//        [selectBtn addTarget:self action:@selector(selectBoxType) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:selectBtn];
    }else {
        UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12, ScreenX375(30))];
        UILabel *rightView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(30), ScreenX375(30))];
        rightView.text = @"kg";
        rightView.textColor = REXADECIMALCOLOR(@"#999999");
        rightView.font = Kfont(13);
        
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(122), ScreenX375(11.5), ScreenX375(109), ScreenX375(30))];
        textField.layer.cornerRadius = ScreenX375(15);
        textField.layer.borderWidth = 0.8;
        textField.layer.borderColor = REXADECIMALCOLOR(@"#dcdcdc").CGColor;
        textField.clipsToBounds = YES;
        textField.leftView = leftView;
        textField.rightView = rightView;
        textField.leftViewMode = UITextFieldViewModeAlways;
        textField.rightViewMode = UITextFieldViewModeAlways;
        [view addSubview:textField];
    }
    
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(53) - 0.5, SCREEN_WIDTH, 0.5)];
    line.backgroundColor = LineColor;
    [view addSubview:line];
    
    return view;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
